

/*
 * Copyright (c) 2017.
 * @author fff
 * 17-10-17 下午4:56
 *
 */

package com.cpit.qualitycontrol.entity;


import com.cpit.platform.common.excel.annotation.ExcelField;

import javax.persistence.*;
import java.util.Date;


@Entity
public class Device {
    @Id
    @ExcelField(title = "设备编号*", type = 0, align = 2, sort = 1)
    private String id;


    @ExcelField(title = "设备名称*", type = 0, align = 2, sort = 1)
    @Column(nullable = false, length = 50, unique = true)
    private String name;

    @ExcelField(title = "设备地址", type = 0, align = 2, sort = 1)
    @Column(length = 500)
    private String addrs;

    /*
   设备 类型Id
    */

    @Column(nullable = false)
    private Long deviceTypeId = 0L;

    /*设备类型名称*/
    @ExcelField(title = "设备类型*", type = 0, align = 2, sort = 1)
    @Transient
    private String deviceTypeName;

    @ExcelField(title = "设备型号", type = 0, align = 2, sort = 1)
    @Column(length = 50)
    private String version;
    /**
     * 设备厂家
     */
    @ExcelField(title = "设备厂家", type = 0, align = 2, sort = 1)
    @Column(length = 50)
    private String vendor;

    /**
     * 经度
     */
    @ExcelField(title = "经度", type = 0, align = 2, sort = 1, fieldType = String.class, decimalFormat = "#.#######")
    private Double longitude = 0.0;
    /**
     * 纬度
     */
    @ExcelField(title = "纬度", type = 0, align = 2, sort = 1, fieldType = String.class, decimalFormat = "#.#######")
    private Double latitude = 0.0;

    /**
     * 项目id
     */
    @Column(nullable = false)
    private Long projectId;
    /**
     * 项目名称
     */
    @ExcelField(title = "项目归属*", type = 0, align = 2, sort = 1)
    @Transient
    private String projectName;

    /**
     * 产品线id
     */

    @Column(nullable = false)
    private Long productLineId;
    /**
     * 产品线名称
     */
    @ExcelField(title = "产品线*", type = 0, align = 2, sort = 1)
    @Transient
    private String productLineName;
    /**
     * 设备来源，又这个字段用作表示状态
     */
//    @ExcelField(title = "状态", type = 0, align = 2, sort = 1)
    @Column(length = 50)
    private String source;

    /**
     * 备注
     */
    @ExcelField(title = "备注", type = 0, align = 2, sort = 1)
    @Column(length = 500)
    private String note;

    /**
     * 创建时间
     */
    @Temporal(TemporalType.TIMESTAMP)
    @Column(updatable = false, columnDefinition = "DATETIME COMMENT '创建时间'")
    @org.hibernate.annotations.CreationTimestamp
    private Date createTime;

    public Device() {
    }

    public Device(String id, String name, String addrs, Long deviceTypeId, String deviceTypeName, String version, String vendor, double longitude, double latitude, Long projectId, String projectName, Long productLineId, String productLineName, String source, String note) {
        this.id = id;
        this.name = name;
        this.addrs = addrs;
        this.deviceTypeId = deviceTypeId;
        this.deviceTypeName = deviceTypeName;
        this.version = version;
        this.vendor = vendor;
        this.longitude = longitude;
        this.latitude = latitude;
        this.projectId = projectId;
        this.projectName = projectName;
        this.productLineId = productLineId;
        this.productLineName = productLineName;
        this.source = source;
        this.note = note;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddrs() {
        return addrs;
    }

    public void setAddrs(String addrs) {
        this.addrs = addrs;
    }

    public Long getDeviceTypeId() {
        return deviceTypeId;
    }

    public void setDeviceTypeId(Long deviceTypeId) {
        if (deviceTypeId != null)
            this.deviceTypeId = deviceTypeId;
    }

    public String getDeviceTypeName() {
        return deviceTypeName;
    }

    public void setDeviceTypeName(String deviceTypeName) {
        this.deviceTypeName = deviceTypeName;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getVendor() {
        return vendor;
    }

    public void setVendor(String vendor) {
        this.vendor = vendor;
    }

    public Double getLongitude() {
        return longitude;
    }

    public void setLongitude(Double longitude) {
        if (longitude != null)
            this.longitude = longitude;
    }

    public Double getLatitude() {
        return latitude;
    }

    public void setLatitude(Double latitude) {
        if (latitude != null)
            this.latitude = latitude;
    }

    public Long getProjectId() {
        return projectId;
    }

    public void setProjectId(Long projectId) {
        this.projectId = projectId;
    }

    public String getProjectName() {
        return projectName;
    }

    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }

    public Long getProductLineId() {
        return productLineId;
    }

    public void setProductLineId(Long productLineId) {
        this.productLineId = productLineId;
    }

    public String getProductLineName() {
        return productLineName;
    }

    public void setProductLineName(String productLineName) {
        this.productLineName = productLineName;
    }

    public String getSource() {
        return source;
    }

    public void setSource(String source) {
        this.source = source;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    @Override
    public String toString() {
        return "Device{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", addrs='" + addrs + '\'' +
                ", deviceTypeId=" + deviceTypeId +
                ", deviceTypeName='" + deviceTypeName + '\'' +
                ", version='" + version + '\'' +
                ", vendor='" + vendor + '\'' +
                ", longitude=" + longitude +
                ", latitude=" + latitude +
                ", projectId=" + projectId +
                ", projectName='" + projectName + '\'' +
                ", productLineId=" + productLineId +
                ", productLineName='" + productLineName + '\'' +
                ", source='" + source + '\'' +
                ", note='" + note + '\'' +
                '}';
    }
}
